package com.demo;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class MyHttpServlet
 */
public class MyHttpServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public MyHttpServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	System.out.println("in do get method");
	String requestHeader=	 request.getHeader("User-Agent");
	  response.setContentType("text/html");
	  System.out.println(request.getMethod());
	PrintWriter printWriter=    response.getWriter();  
	System.out.println(requestHeader);
	if(requestHeader.indexOf("Firefox")!=-1){
	  printWriter.println("you are using firefox");
	}
	if(requestHeader.indexOf("Chrome")!=-1){
		
		printWriter.println("you are using chrome");
	}
	  
	
	printWriter.write("<form action='LoginServlet' method='POST' >"
			+ "User Name:<input type='text' name='username'><br>"
			+ "Password :<input type='password' name='password'><br>"
			+ "<input type='submit' value='Login'>"
			+ "</form>");
	
	
	
	
	
	
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		System.out.println("in do post method..");
		
		
	}

}
